package leetcode_5000;

public class _形成字符串的最短路径 {
	public static void main(String[] args) {
		_形成字符串的最短路径 test  =  new _形成字符串的最短路径();
		System.out.println(test.help("xyz", "xzyxz"));
		System.out.println(test.help("abc", "acdbc"));
		System.out.println(test.help("abc", "abcbc"));
	}
	
	public int help(String source,String target) {
		char[] s = source.toCharArray();
		char[] t= target.toCharArray();
		int res = 0,j=0;
		while(j < target.length()) {
			int run = j;
			for(int i = 0;i<s.length;++i) {
				if(s[i] == t[j]) {
					++j;
				}
			}
			if(run == j) return -1;
			++res;
		}
		return res;
	}
}
